package com.nmh.config;

import com.nmh.service.userService;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class MetaObjectHandler implements com.baomidou.mybatisplus.core.handlers.MetaObjectHandler {
    @Autowired
    private userService userService;
    @Override
    public void insertFill(MetaObject metaObject) {
//        this.strictInsertFill(metaObject, "createTime", Date.class,new Date());
//        this.strictInsertFill(metaObject, "updateTime", Date.class,new Date());
//        int count=(int)userService.count()+1;
//        String Acoount="YZ"+"000"+count;
        metaObject.setValue("updateTime", LocalDateTime.now());
        metaObject.setValue("createTime", LocalDateTime.now());
//        metaObject.setValue("userAccount",Acoount);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
//        this.setFieldValByName("updateTime", new Date(), metaObject);
        metaObject.setValue("updateTime", LocalDateTime.now());
    }
}
